<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/17 0017
 * Time: 15:19
 */

namespace app\admin\controller;


use think\Request;

class Zhichi extends Base
{
    protected $_Message;
    protected $_product;
    public function __construct(Request $request = null){
        parent::__construct($request);
        $this->_Message = new \app\model\model\Zhichi();
    }
    public function lists(){

        return $this->fetch();
    }
    public function getList(){
        $where = [];
        $name = input('name');
        if($name){
            $where['name'] = ['like',"%$name%"];
        }
        $data = $this->_Message->getList($where,input('limit'));
        foreach ($data as $v){
            $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
            if($v['type']==1){
                $v['type'] = '技术支持';
            }else{
                $v['type'] = '申请打样';
            }
        }
        $list = $data->toArray();


        echo json_echo($list);
    }

    /**
     * 获取一条数据
     * */
    public function getOne(){
        $data = $this->_Message->getOne(input('id'));
        echo json_echo_msg(200,'成功',$data);
    }
    /**
     * 删除
     * */
    public function del(){
        $re = $this->_Message->del(['id'=>input('id')]);
        if($re){
            return json_echo_msg(200,'删除成功！');
        }else{
            return json_echo_msg(400,'删除失败！');
        }
    }
    /**
     * 批量删除
     * */
    public function delAll(){
        $re = $this->_Message->delAll(input()['data']);
        if($re){
            return json_echo_msg(200,'删除成功！');
        }else{
            return json_echo_msg(400,'删除失败！');
        }
    }
}